#include <iostream>
using namespace std;
class Complex
{
  friend ostream &operator<<(ostream &out, Complex &c);
  friend istream &operator>>(istream &in, Complex &c);

public:
  Complex(double r = 1, double m = 1)
  {
    real = r;
    imag = m;
  }
  Complex operator+(Complex b)
  {
    Complex c;
    c.real = real + b.real;
    c.imag = imag + b.imag;
    return c;
  }

private:
  double real, imag;
};
ostream &operator<<(ostream &out, Complex &c)
{
  if (c.imag > 0)
    out << c.real << "+" << c.imag << "i" << endl;
  else
    out << c.real << "+(" << c.imag << ")i" << endl;
  return out;
}
istream &operator>>(istream &in, Complex &c)
{
  cout << "请输入复数的实部和虚部：" << endl;
  in >> c.real >> c.imag;
  return in;
}
int main()
{
  Complex a, b, c;
  cin >> a >> b;
  c = a + b;
  cout << "两个复数之和为：" << c << endl;
  return 0;
}
